import {useState} from "react";
import {Button} from 'antd';

export default function UserInfo(props) {
  let [created,setCreated] = useState(props.user.created);
  async function changeFormat() {
    const moment = await import('moment');
    setCreated(moment.default(props.user.created).fromNow());
  }
  return (
    <div>
      <p>用户名:{props.user.username}</p>
      <p>密码:{props.user.password}</p>
      <p>创建时间:{created}</p>
      <Button onClick={changeFormat}>转成相对时间</Button>
    </div>
  )
}
